package com.corn.skywalking.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * @author : Jim Wu
 * @version 1.0
 * @function :
 * @since : 2021/4/23 16:15
 */
@Slf4j
@RestController
public class TestController {

    @GetMapping("slow")
    public String slow() throws InterruptedException {
        TimeUnit.SECONDS.sleep(2);
        return "slow";
    }

    @GetMapping("test")
    public String test() {
        log.info("test6666");
        return "test";
    }

    @PostMapping("webhook")
    public void webhook(@RequestBody List<SkyWalkingAlarmMessage> messages) {
        messages.forEach(System.out::println);
    }

//    @GetMapping("/test/log")
//    public void testLog(){
//        ILog logger = LogManager.getLogger(TestController.class);
//        logger.info("test skyWalking log");
//    }
//
//    @GetMapping("/test/alarm")
//    public void testAlarm(){
//        ILog logger = LogManager.getLogger(TestController.class);
//        log.info("SkyWalking TranceId: {}",ContextManager.getGlobalTraceId());
//        logger.info("test skyWalking log");
//    }
}
